package com.capgemini.cn.authority.data.repository;

import com.capgemini.cn.authority.data.entity.AuthoritiesType;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Lock;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import javax.persistence.LockModeType;

/**
 * Created at 2017/8/24
 *
 * @author Andriy
 */
@Repository
public interface AuthoritiesTypeRepository extends JpaRepository<AuthoritiesType, Long> {

    /**
     * 根据类型名称查询权限类型信息 - <span style='color:yellow'>使用悲观写锁控制数据脏读</span>
     *
     * @param typeName 权限类型名称
     */
    @Lock(value = LockModeType.PESSIMISTIC_WRITE)
    AuthoritiesType findByTypeNameEquals(@Param(value = "typeName") String typeName);
}
